package com.hzdl.cinema.web.servlet;

import com.hzdl.cinema.Service.SearchSeatService;
import com.hzdl.cinema.Service.impl.SearchSeatServiceImpl;
import com.hzdl.cinema.domain.Seat;
import com.hzdl.cinema.domain.Ticket;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/searchSeat/*")
public class SearchSeatServlet extends BaseServlet {
    SearchSeatService searchSeatService = new SearchSeatServiceImpl();

    //购票
    public void buyTickets(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String playName = request.getParameter("playName");
        Ticket ticket = searchSeatService.buyTickets(playName);
        writeValue(response, ticket);

    }

    //确认购票
    public void confirm(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String ticketId = request.getParameter("ticketId");
        String userId = request.getParameter("userId");
        searchSeatService.confirm(Integer.parseInt(userId),ticketId);
        writeValue(response,"购买成功！");
    }
}
